class SessionsController < ApplicationController
  before_filter :authenticate_user, :only => [:delete]
  before_filter :save_login_state, :only => [:new, :create]
  def new
    render :layout => "frontends"
  end

  def create
    user = User.find_by_email(params[:email])
    if user && user.authenticate(params[:password])
      session[:user_id] = user.id
      redirect_to :controller =>:product_backlogs, :action => :show 
    else
      params[:error] = "Email oder Passwort inkorrekt"
      render "new",:layout => "frontends"
    end
  end

  def delete
    session[:user_id] = nil
      render "new",:layout => "frontends", :notice => "Logged out!"
  end
end
